package com.java复习.IO流;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class demo4 {
    // 进行文件的复制======读取文件到内存，输出文件到磁盘
    public static void main(String[] args) throws IOException {
        FileInputStream fis = new FileInputStream("D:\\Desktop\\a.txt");
        FileOutputStream fos = new FileOutputStream("D:\\Desktop\\b.txt");
        byte[] b = new byte[1024];  // 缓存数组

        int lengh = 0;
        // 边读取边写入
        while ((lengh = fis.read()) != -1){
            fos.write(b,0,lengh);
        }
        fos.close();  // 后开启的先关闭
        fis.close();
    }
}
